<!--
 * @Description: 
 * @version: 
 * @Author: m
 * @LastEditors: m
-->
<template>
	<div class="container">
		<van-address-list v-model="chosenAddressId" :list="list"  default-tag-text="默认" @add="onAdd" @edit="onEdit" />
	</div>
</template>

<script>
import { get } from "@/api/address.js";
export default {
	data() {
		return {
			chosenAddressId: "1",
			list: [],
		};
	},

  created:function(){
    get()
        .then((res) => {
        console.log(res)
        this.list = res.data
        this.chosenAddressId="1";
    })
        .catch((res) => {
          console.log(res);
          return this.$toast.fail("网络连接错误,请稍后重试!");
        });
  },
  methods: {
		onAdd() {
			this.$router.push({ path: "/address/add" });
		},
		onEdit(item, index) {
			this.$router.push({
        path: "/address/add" ,
          query:{
            paId:index
          }}
			);
			console.log("编辑地址:" + this.list[index].id);
		},

	},
};
</script>
<style lang="scss">
#app {
	width: 100%;
	height: 100%;
	background-color: #f7f8fa;
}
.container {
	width: 100%;
	height: 100%;
	background-color: #f7f8fa;
}
</style>
